package com.myhome.money.base.test;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author: 许路路
 * @Date: 2019/4/3
 */
public class Task {

    final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);

    public static void main(String[] args) {
        Task task = new Task();
        task.test();
    }

    public void test() {
        //每10s去刷新
        executor.scheduleWithFixedDelay(() -> {
            System.out.println("111111111111111111");
        }, 5, 2, TimeUnit.SECONDS);
        //取消的订单更新数据库订单状态
        executor.schedule(() -> {
            for (; ; ) {
                System.out.println("222222222222222");
                Thread.sleep(1000);
            }
        }, 10, TimeUnit.SECONDS);
    }
}
